using System;
using System.Collections.Generic;
using System.Text;

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

using JiggleGame.PhysicObjects;

namespace GopacarsNetworkPrototype
{
    class Player : CarObject
    {
        public PlayerSteerActions nextSteerAction = PlayerSteerActions.NONE;
        public PlayerPedalActions nextPedalAction = PlayerPedalActions.NONE;
        public enum PlayerSteerActions
        {
            NONE, RIGHT, LEFT
        }
        public enum PlayerPedalActions
        {
            NONE, ACCELERATE, BREAK
        }


        public Player(Game game, Model model, Model wheels, bool FWDrive,
               bool RWDrive,
               float maxSteerAngle,
               float steerRate,
               float wheelSideFriction,
               float wheelFwdFriction,
               float wheelTravel,
               float wheelRadius,
               float wheelZOffset,
               float wheelRestingFrac,
               float wheelDampingFrac,
               int wheelNumRays,
               float driveTorque,
               float gravity)
            : base(game, model, wheels, FWDrive, RWDrive, maxSteerAngle, steerRate, wheelSideFriction, wheelFwdFriction,
                   wheelTravel, wheelRadius, wheelZOffset, wheelRestingFrac, wheelDampingFrac, wheelNumRays, driveTorque, gravity)
        { }        

 
        /// <summary>
        /// Update physics forces on player depending on next requested action.
        /// </summary>
        /// <param name="gameTime"></param>
        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);


            switch (nextSteerAction)
            {
                case PlayerSteerActions.RIGHT:
                    Car.Steer = -2.0f;
                    break;
                case PlayerSteerActions.LEFT:
                    Car.Steer = 2.0f;
                    break;
                default:
                    Car.Steer = 0.0f;
                    break;
            }
            nextSteerAction = PlayerSteerActions.NONE;

            switch (nextPedalAction)
            {
                case PlayerPedalActions.ACCELERATE:
                    Car.Accelerate = 1.0f;
                    break;
                case PlayerPedalActions.BREAK:
                    Car.Accelerate = -2.0f;
                    break;
                default:
                    Car.Accelerate = 0.0f;
                    break;
            }
            nextPedalAction = PlayerPedalActions.NONE;
        
        }



    }
}
